package com.aioething.iot.beans;

import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@Data
public class EmqxClient {
    private List<Data> data;

    @lombok.Data
    public static class Data {
        private String clientid;
        private Boolean connected;
    }

    public List<String> getOnlineClient() {
        if (CollectionUtils.isEmpty(data))  return new ArrayList<>();
        return data.stream().filter(c->Boolean.TRUE.equals(c.connected)).map(Data::getClientid).collect(Collectors.toList());
    }
}
